<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<rich:modalPanel id="registerModalPanel" minHeight="290" minWidth="360" height="290" width="360">
    <f:facet name="header">
        <h:outputText value="Регистрация" />
    </f:facet>
    <f:facet name="controls">
        <a4j:form>
            <h:panelGroup>
                <h:graphicImage value="/images/close.png" style="cursor: pointer;" id="closeRegistrationDialog">
                    <a4j:support event="onclick" immediate="true" action="#{registerBean.clear}" reRender="userAuthGroup"/>
                </h:graphicImage>
                <rich:componentControl for="registerModalPanel" attachTo="closeRegistrationDialog" operation="hide" event="onclick"/>
            </h:panelGroup>
        </a4j:form>
    </f:facet>
    <a4j:form id="registerForm">
        <h:panelGrid id="registerTable" rowClasses="registration-label,registration-input,registration-message"
                columns="2" columnClasses="registration-column-first,registration-column-second">
            <h:outputText value="Имя"/>
            <h:outputText value="Фамилия"/>

            <h:inputText value="#{registerBean.firstName}" id="regFirstName" style="float: left;" disabled="#{registerBean.registered}">
                <rich:ajaxValidator event="onblur"/>
            </h:inputText>
            <h:inputText value="#{registerBean.lastName}" id="regLastName" style="float: left;" disabled="#{registerBean.registered}">
                <rich:ajaxValidator event="onblur"/>
            </h:inputText>

            <rich:message for="regFirstName"/>
            <rich:message for="regLastName"/>

            <h:outputText value="Адрес электронной почты"/>
            <h:outputText value=" "/>

            <h:inputText value="#{registerBean.email}" id="regEmail" style="float: left;" disabled="#{registerBean.registered}">
                <rich:ajaxValidator event="onblur"/>
            </h:inputText>
            <h:outputText value=" "/>

            <rich:message for="regEmail"/>
            <h:outputText value=" "/>
            

            <h:outputText value="Логин"/>
            <h:outputText value=" "/>

            <h:inputText value="#{registerBean.login}" id="regLogin" style="float: left;" disabled="#{registerBean.registered}">
                <rich:ajaxValidator event="onblur"/>
            </h:inputText>
            <h:outputText value=" "/>

            <rich:message for="regLogin"/>
            <h:outputText value=" "/>

            
            <h:outputText value="Пароль"/>
            <h:outputText value="Подтверждение пароля"/>

            <h:inputSecret value="#{registerBean.password}" id="regPass" style="float: left;" disabled="#{registerBean.registered}">
                <rich:ajaxValidator event="onblur"/>
            </h:inputSecret>

            <h:inputSecret value="#{registerBean.confirmPassword}" id="regConfirmPass" style="float: left;" disabled="#{registerBean.registered}">
                <rich:ajaxValidator event="onblur"/>
            </h:inputSecret>

            <rich:message for="regPass"/>
            <rich:message for="regConfirmPass"/>
            
        </h:panelGrid>
        <a4j:commandButton id="registerCommand" value="Послать" actionListener="#{registerBean.doRegisterListener}" 
                action="#{registerBean.doRegister}" styleClass="registration-button" rendered="#{!registerBean.registered}" 
                reRender="registerForm,registerCommand,registeredText"/>
        <h:outputText id="registeredText" value="Поздравляем, регистрация прошла успешно!" styleClass="happy-new-user-label" 
                rendered="#{registerBean.registered}"/>
        <rich:hotKey key="return" handler="#{rich:element('registerCommand')}.click(); return false;" checkParent="true" rendered="#{!registerBean.registered}"/>
    </a4j:form>
</rich:modalPanel>